You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

29 lines
773 B

import { requireAdmin } from "#server/utils/admin-guard";
import { createModel } from "#server/service/llm";
export default defineWrappedResponseHandler(async (event) => {
await requireAdmin(event);
const providerId = Number(getRouterParam(event, "providerId"));
if (!providerId) {
return R.throwError(400, "无效的供应商ID", null);
}
const body = await readBody(event);
const { name, modelId, type, enabled, description, maxTokens } = body;
if (!name || !modelId) {
return R.throwError(422, "模型名称和模型ID不能为空", null);
}
const result = await createModel({
providerId,
name,
modelId,
type: type || "text",
enabled: enabled ?? 1,
description,
maxTokens,
});
return R.success(result);
});